{extend name="ace/layout/default" /}

{block name="title"}省市区管理{/block}

{block name="content"}
<h3 class="header smaller lighter blue">
    省市区列表
    <small>
        <i class="icon-double-angle-right"></i>
        Province and city list
    </small>
</h3>
<div class="row">
    <?php $parent_id = input('parent_id', 0); ?>
    <div class="col-xs-12 col-sm-12 col-ml-12">
        <a href="{:url('detail') }">
            <button class="btn btn-sm btn-success">
                <i class="icon-zoom-in bigger-120"></i>
                添加省市区
            </button>
        </a>
        {if $parent_id}
        <a href="{:url('detail', ['parent_id' => $parent_id]) }">
            <button class="btn btn-sm btn-success">
                <i class="icon-zoom-in bigger-120"></i>
                添加当前主栏目的下级
            </button>
        </a>
        {/if}
    </div>
    <div class="col-xs-12 col-sm-12 col-ml-12">
        <div class="space-4"></div>
        <form action="" method="get" id="form_data" class="first_form float-left">
            <?php $level = input('level', $parent_id == 0 ? 1 : -1); ?>
            <input type="hidden" name="parent_id" value="{$parent_id}" />
            <select name="level">
                <option value="-1" {$level == -1 ? 'selected' : ''}> 请选择层级 </option>
                <option value="1" {$level == 1 ? 'selected' : ''}> 省 </option>
                <option value="2" {$level == 2 ? 'selected' : ''}> 市 </option>
                <option value="3" {$level == 3 ? 'selected' : ''}> 区 </option>
            </select>
            <span class="input-icon">
                <input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input"
                       autocomplete="off" name="search" value="{:input('search', '')}"/>

                <button type="button" class="btn btn-purple btn-sm" onclick="$('form.first_form').submit();">
                    Search
                    <i class="icon-search icon-on-right bigger-110"></i>
                </button>
            </span>
        </form>
    </div>
</div>
<div class="space-4"></div>
<div class="table-header">Province and city list</div>
<div class="table-responsive">
    <table id="sample-table-1" class="table table-striped table-bordered table-hover">
        <thead>
        <tr>
            <th class="center">
                <label>
                    <input type="checkbox" class="ace" name="region_id[]" />
                    <span class="lbl"></span>
                </label>
            </th>
            <th class="text-center"> Id </th>
            <th class="text-center"> 名称 </th>
            <th class="text-center"> 层级 </th>
            <!--
            <th class="text-center hidden-sm hidden-xs"> 简称 </th>
            <th class="text-center hidden-sm hidden-xs hidden-md"> 全称 </th>
            <th class="text-center hidden-sm hidden-xs hidden-md"> 层级 </th>
            <th class="text-center hidden-sm hidden-xs hidden-md"> 拼音 </th>
            <th class="text-center hidden-sm hidden-xs hidden-md"> 首字母 </th>
            -->
            <th class="text-center"> 操作 </th>
        </tr>
        </thead>
        <tbody>
        {if !empty($list) && $list->total()}
        {foreach $list as $key => $item}
        <tr id="id_{$item->region_id}" name="{$item->name}">
            <td class="text-center">
                <label>
                    <input type="checkbox" class="ace" name="region_id[]" value="{$item->region_id}" />
                    <span class="lbl"></span>
                </label>
            </td>
            <td class="text-center"> <a href="javascript:;">{$item->region_id}</a> </td>
            <td class="text-center"> {$item->name} </td>
            <td class="text-center">
                {switch $item->level|intval}
                {case 1}
                省份
                {/case}
                {case 2}
                城市/直辖市
                {/case}
                {case 3}
                区/县
                {/case}
                {/switch}
            </td>
            <!--
            <td class="text-center hidden-sm hidden-xs"> {$item->shortname} </td>
            <td class="text-center hidden-sm hidden-xs hidden-md"> {$item->merger_name} </td>
            <td class="text-center hidden-sm hidden-xs hidden-md"> {$item->level} </td>
            <td class="text-center hidden-sm hidden-xs hidden-md"> {$item->pinyin} </td>
            <td class="text-center hidden-sm hidden-xs hidden-md"> {$item->first} </td>
            -->
            <td class="text-center">
                <div class="hidden-sm hidden-xs action-buttons">
                    {if $item->level < 3}
                    <a class="btn btn-xs btn-success" title="查看“{$item->name}”的下级" href="{:url('', ['parent_id' => $item->region_id])}">
                        <i class="icon-eye-open bigger-120"></i> 查看下级
                    </a>
                    {/if}
                    <a class="btn btn-xs btn-info" title="编辑“{$item->name}”区域" href="{:url('detail', ['region_id' => $item->region_id])}">
                        <i class="icon-edit bigger-120"></i> 编辑
                    </a>
                    <a class="btn btn-xs btn-danger" title="删除“{$item->name}”区域" onclick="delOperation({$item->region_id}, '{:url(\'delete\')}')">
                        <i class="icon-trash bigger-120"></i> 删除
                    </a>
                </div>
                <div class="hidden-md hidden-lg">
                    <div class="inline position-relative">
                        <button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown" data-position="auto">
                            <i class="icon-cog bigger-110"></i>
                        </button>
                        <ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
                            {if $item->level < 3}
                            <li>
                                <a class="btn btn-xs btn-success" title="查看“{$item->name}”的下级" href="{:url('', ['parent_id' => $item->region_id])}">
                                    <i class="icon-eye-open bigger-120"></i> 查看下级
                                </a>
                            </li>
                            {/if}
                            <li>
                                <a class="btn btn-xs btn-info" title="编辑“{$item->name}”区域" href="{:url('detail', ['region_id' => $item->region_id])}">
                                    <i class="icon-edit bigger-120"></i> 编辑
                                </a>
                            </li>
                            <li>
                                <div class="hr hr-dotted"></div>
                                <a class="btn btn-xs btn-danger" title="删除“{$item->name}”区域" onclick="delOperation({$item->region_id}, '{:url(\'delete\')}')">
                                    <i class="icon-trash bigger-120"></i> 删除
                                </a>
                            </li>
                        </ul>
                    </div>
                </div>
            </td>
        </tr>
        {/foreach}
        {/if}
        </tbody>
    </table>

    <div class="hr hr-18 dotted hr-double"></div>

    {if !empty($list) && $list->total()}
    <div id="pageList" class="float-right">
        {$list|raw}
    </div>
    {/if}
</div><!-- /.table-responsive -->
{/block}